package com.tomj.toolbox.auto;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @Auther: tomj
 * @Date: 2019-03-05 16:15
 * @Description:
 */
public class Auto {
    private String db;
    private String tableName;
    private List<AType> types;
    private String operationType;

    public String getOperationType() {
        return operationType;
    }

    public void setOperationType(String operationType) {
        this.operationType = operationType;
    }

    public String getDb() {
        return db;
    }

    public void setDb(String db) {
        this.db = db;
    }

    public String getTableName() {
        return tableName;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;
    }

    public List<AType> getTypes() {
        return types;
    }

    public void setTypes(List<AType> types) {
        this.types = types;
    }

    public enum AType{
        ENTITY,VO,MAPPERXML,DAO,SERVICE,SERVICEIMPL,CONTROLLER;
    }

    public static Auto model(String model){
        Auto auto = new Auto();
        auto.db = model;
        return  auto;
    }

    public Auto table(String tableName){
        this.tableName = tableName;
        return this;
    }

    public Auto excludeXml(){
        this.types = new ArrayList<AType>();
        this.types.addAll(Arrays.asList(AType.ENTITY, AType.VO, AType.DAO, AType.SERVICE, AType.SERVICEIMPL, AType.CONTROLLER));
        return this;
    }

    public Auto all(){
        this.types = new ArrayList<AType>();
        this.types.addAll(Arrays.asList(AType.ENTITY, AType.VO, AType.MAPPERXML, AType.DAO, AType.SERVICE, AType.SERVICEIMPL, AType.CONTROLLER));
        return this;
    }

    public Auto include(AType... types){
        this.types = Arrays.asList(types);
        return this;
    }

}
